package m2.binding;

import m2.port.PortConfigFourni;
import m2.port.PortFourni;

public class BindingF extends Binding {
	protected PortConfigFourni portConfigFournis;
	protected PortFourni portFourni;
	
	public BindingF(String name, PortConfigFourni portConfigFournis,
			PortFourni portFournis, TypeBinding type) {
		super(name,type);
		this.portConfigFournis = portConfigFournis;
		this.portFourni = portFournis;
		if (TypeBinding.PortComp2PortConf==type) {
			portConfigFournis.addObserver(this);
			this.addObserver(portFournis);
		} else if (TypeBinding.PortConf2PortComp==type)  {
		
			
			portFournis.addObserver(this);
			this.addObserver(portConfigFournis);
			
		}
	}

	public PortConfigFourni getPortConfigFournis() {
		return portConfigFournis;
	}

	public void setPortConfigFournis(PortConfigFourni portConfigFournis) {
		deleteObserver(this.portConfigFournis);
		this.portConfigFournis = portConfigFournis;
		this.addObserver(this.portConfigFournis);
	}

	public PortFourni getPortFournis() {
		return portFourni;
	}

	public void setPortFournis(PortFourni portFourni) {
		this.portFourni.deleteObserver(this);
		this.portFourni = portFourni;
		this.portFourni.addObserver(this);

	}

	@Override
	public void update(Object o, Object arg) {
		System.out.println( name + " redirection du message " +  arg + "\n\n");
		notifyObservers(arg);
	}
}
